import wx from 'weixin-js-sdk'
import { getWechatShareInfo } from '@/api'

(async () => {
  const { code, shareInfo, signPackage } = await getWechatShareInfo()
  if (code === 1) {
    wx.config({
      ...signPackage,
      jsApiList: [
        'checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage'
      ]
    })
    wx.ready(() => {
      wx.checkJsApi({
        jsApiList: [
          'onMenuShareTimeline',
          'onMenuShareAppMessage'
        ]
      })
      wx.onMenuShareTimeline(shareInfo)
    })
  }
})()
